package com.wicket.okrbff.base.service.impl;

import com.wicket.okrbff.base.service.AdCodeInfoService;
import com.wicket.okrbff.base.service.dto.req.BffAdInfoRepDto;
import com.wicket.okrbff.dal.mapper.mbg.OmsCommonAdinfoMapper;
import com.wicket.okrbff.dal.po.mbg.OmsCommonAdinfo;
import com.wicket.okrbff.dal.po.mbg.OmsCommonAdinfoExample;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;


/**
 * @author ：CHS
 * @since 2022/3/28 14:43
 *
 *
 * @version 1.0
 */
@Service
public class AdCodeInfoServiceImpl implements AdCodeInfoService {

    @Autowired
    OmsCommonAdinfoMapper mapper;

    @Override
    public List<OmsCommonAdinfo> queryList(BffAdInfoRepDto req) {
        OmsCommonAdinfoExample example = new OmsCommonAdinfoExample();
        OmsCommonAdinfoExample.Criteria criteria = example.createCriteria();
        if (req.getAdcode() != null && !req.getAdcode().isEmpty()) criteria.andAdcodeEqualTo(req.getAdcode());
        if (req.getCitycode() != null && !req.getCitycode().isEmpty()) criteria.andCitycodeEqualTo(req.getCitycode());

        if (req.getAdcode() == null && req.getAdcode().isEmpty() && req.getCitycode() == null && req.getCitycode().isEmpty()) {
            criteria.andAdcodeEqualTo("-1");
        }
        return mapper.selectByExample(example);
    }
}
